<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <base href="${pageContext.servletContext.contextPath}/">
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="static/js/layuia/css/layui.css" media="all">
    <link rel="stylesheet" href="static/css/layui/public.css" media="all">
    <style>
        .layui-form{
            font-style: normal;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <a type="submit" class="layui-btn layui-btn-primary" href="entrust/downloadtable"><i class="fa fa-file-text-o" aria-hidden="true"/> 下载模板
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

<%--        <script type="text/html" id="toolbarDemo">--%>
<%--            <div class="layui-btn-container">--%>
<%--                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 开始查询</button>--%>
<%--                <a class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" href="entrust/downloadtable"> 下载模板--%>
<%--                </a>--%>
<%--            </div>--%>
<%--        </script>--%>

        <table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>

<%--        <script type="text/html" id="currentTableBar">--%>
<%--            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>--%>
<%--            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>--%>
<%--        </script>--%>
    </div>
</div>
<%--layui模板引擎--%>
<script type="text/html" id="setStatus">
    <input type="checkbox" name="close" id="{{d.listStaus}}"
           {{#  if(d.listStaus === 1){ }}
           checked=""
           {{#  } else { }}

           {{#  } }}
           lay-skin="switch" lay-text="正常|禁用"  disabled lay-filter="switchTest"/>
</script>

<script src="static/js/layuia/layui.js" charset="utf-8"></script>
<script >
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
        var table = layui.table;
        var laydate = layui.laydate;
        table.render({
            elem: '#LAY_table_user'
            , url: 'entrust/showlist'
            , cols: [[
                {checkbox: true, fixed: true}
                , {field: 'listId', title: '清单号', width: 100, sort: true, fixed: true}
                , {field: 'listName', title: '清单名称', width: 100}
                , {field: 'amountDue', title: '应发金额', width: 120, sort: true}
                , {field: 'tax', title: '税金', width: 100}
                , {field: 'actualAmount', title: '实发金额',width: 100}
                , {field: 'createDate', title: '创建时间', sort: true, width: 110}
                , {field: 'countMoth', title: '计税月份', sort: true, width: 120}
                , {field: 'expenseCardnumber', title: '经费卡号', width: 100}
                , {field: 'listStaus', title: '清单状态', sort: true, width: 135,templet:'#setStatus'}
            ]]
            , id: 'testReload'
            , page: true
            , height: 350
            , limits: [10, 20, 30]  //一页选择显示3,5或10条数据
            , limit: 10  //一页显示10条数据
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                var result;
                if (this.page.curr) {
                    result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                } else {
                    result = res.data.slice(0, this.limit);
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": result //解析数据列表
                };
            }

        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
           var listname  =  $("#listName").val();
            table.render({
                elem: '#LAY_table_user'
                , url: 'entrust/showlistByName?name='+listname
                , cols: [[
                    {checkbox: true, fixed: true}
                    , {field: 'listId', title: '清单号', width: 100, sort: true, fixed: true}
                    , {field: 'listName', title: '清单名称', width: 100}
                    , {field: 'amountDue', title: '应发金额', width: 120, sort: true}
                    , {field: 'tax', title: '税金', width: 100}
                    , {field: 'actualAmount', title: '实发金额',width: 100}
                    , {field: 'createDate', title: '创建时间', sort: true, width: 110}
                    , {field: 'countMoth', title: '计税月份', sort: true, width: 120}
                    , {field: 'expenseCardnumber', title: '经费卡号', width: 100}
                    , {field: 'listStaus', title: '清单状态', sort: true, width: 135,templet:'#setStatus'}
                ]]
                , id: 'testReload'
                , page: true
                , height: 350
                , limits: [10, 20, 30]  //一页选择显示3,5或10条数据
                , limit: 10  //一页显示10条数据
                , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                    var result;
                    if (this.page.curr) {
                        result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                    } else {
                        result = res.data.slice(0, this.limit);
                    }
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": result //解析数据列表
                    };
                }

            });

            //执行搜索重载
            // table.reload('testReload', {
            //     page: {
            //         curr: 1
            //     }
            //     , where: {
            //         searchParams: result
            //     }
            // }, 'data');

            return false;
        });

        // //监听表格复选框选择
        // table.on('checkbox(currentTableFilter)', function (obj) {
        //     console.log(obj)
        // });
    });




</script>

</body>
</html>
